revision:
The property returns the width of an element, including padding, excluding borders, scrollbars or margins. It returns the width in pixels.
The property is read-only.
Syntax:
element.scrollWidth : returns the width of the element, in pixels.
property value:
none :
example
<div> <div id="DIV"> <div id="content">Some content..</div> </div> <p id="prop"></p> </div> <style> #DIV{ margin-top: 10px; height: 250px; width: 250px; overflow: auto;} #content{ height: 800px; width: 2000px; padding: 10px; background-color: coral;} </style> <script> const element = document.getElementById("content"); let c = element.scrollHeight; let d = element.scrollWidth; document.getElementById ("prop").innerHTML = "Height: " + c + " Width: " + d; </script>